package util;

import com.google.common.base.Strings;

public class CreateUtil {

    public static void createJdMy(String flag, String[] list, int num) {

        String key = Const.my_code_name.get(flag);

        for (int i = 0; i < num; i++) {
            System.out.println("My" + key + (i + 1) + "=\"" + (Strings.isNullOrEmpty(list[i]) ? "" : list[i]) + "\"");
        }
        System.out.println();

        String forOther = createForOther(key, num);
        System.out.println(forOther);

        System.out.println("===============================================");
        System.out.println();
    }


    public static String createForOther(String name, int num) {
        String str = "";
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= num; i++) {
            sb.append("ForOther").append(name).append(i).append("=\"");
            if (i > 1) {
                for (int j = 1; j < i; j++) {
                    String invi = "${My" + name + j + "}";
                    sb.append(invi).append("@");
                }
            }
            if (i < num) {
                for (int j = i + 1; j <= num; j++) {
                    String invi = "${My" + name + j + "}";
                    sb.append(invi).append("@");
                }
            }
            sb.replace(sb.length() - 1, sb.length(), "");
            sb.append("\"").append("\r\n");
        }
        str = sb.toString();
        return str;
    }

}
